<?php 
include_once ('../../global.php');

$pl_id = $_GET['pl_id'];
$players = matchPlayer($mt_id,$pl_id); 
$sex_id = $players['playerSex'][$pl_id];
$mp_class =$players['classname'][$pl_id];
$cl_id  =$players['playerClass'][$pl_id];
$color = (($mp_class == '男子组') ? '#659e59' : '#659e59');
if((strpos($mp_class,'B')!==false || strpos($mp_class,'B')!==false)  && $rd_id >=2){
	$roundtext = array(
			1 => t('round1'),
			2 => t('round2'),
			3 => t('final_round'),
			4 => '',
	);
	$maxRound = 2;
	//$mt_round = 2;
	$rd_id = 2;
}
else{
	$roundtext = array(
			1 => t('round1'),
			2 => t('round2'),
			3 => t('final_round'),
			4 => '',
	);
	$maxRound = 3;
	//$mt_round = 3;
}
?>

		
			
<?php 

$holeScore = getHoleScore($mt_id,$r=0,$pl_id);        //当前洞和当前轮的topar
$roundgroups =getgroups($mt_id,$pl_id);
$avgscores = getavgscores($mt_id); 



echo '<table class="scoringtable topartable" border="0" cellpadding="0" cellspacing="0" width="100%">
        <tbody>
            <tr>';

for ($r = 1; $r <= $maxRound; $r++) {   
    echo '<td width="15%">
            <div class="poppin num" ' . (($holeScore['thru'][$r][$pl_id] == 18 && $holeScore['roundtopar'][$r][$pl_id] < 0) ? 'style="color:#e50049;"' : '') . '>' . $holeScore['roundscore'][$r][$pl_id] . '</div>
            <div class="poppin numdesc" ' . (($r <= $mt_round) ? ('onclick="setmatchscoreslines(\'' . ($r) . '\')"') : "") . '>
                R' . $r . '
                <text class="divr" id="divr' . $r . '" style="display:none;">▲</text>
            </div>
        </td>';
}

$topar = $holeScore['totaltopar'][$pl_id];        

echo '<td width="20%">
        <div class="poppin num" ' . (($holeScore['totalthru'][$pl_id] % 18 == 0 && $topar < 0) ? 'style="color:#e50049;"' : '') . '>' . $holeScore['totalscore'][$pl_id] . '</div>
        <div class="numdesc ' . $css_class . '">' . t('total_score') . '</div>
    </td>
    <td width="35%">
        <div class="num">
            <div class="topar ' . (($topar < 0) ? 'undereven' : (($topar == 0) ? 'even' : (($topar > 0) ? 'pluseven' : ''))) . '">' . (($topar == '0') ? 'E' : (($topar == '') ? '' : (($topar > 0) ? '+' . $topar : $topar))) . '</div>
        </div>
        <div class="numdesc ' . $css_class . '">' . t('to_par') . '</div>
    </td>
</tr>
</tbody>
</table>';
 

echo '<div id="mychart-line" style="width:100%;height:200px;background-color:transparent;margin-top:10px;margin-bottom:10px;"></div>';
echo '<div class="menu" style="width:100%;height:60px; margin-top:10px;margin-bottom:10px;display:none;"><div class="menubutton">分享成绩海报</div><div class="menubutton">分享技术统计</div></div>';
//获取视频
$user_id=$_SESSION['user_id'];
if(empty($user_id)) {//判断登录
    $video_info=[];
}else{
    $sql = "SELECT * FROM bmw_player_video where pl_id='{$pl_id}' and mt_id='{$mt_id}'";
    $video_info= $db->SelectSQL($sql);
}

//查找到视频
$videos = array();
//$videos[0] = array('id'=>'1','name'=>'球员视频','thurmb'=>'./images/v1.png','src'=>($video_info?$video_info[0]['video']:""));

if(count($video_info)>0){
	//echo '<div style="color:#fff;margin-left:5px;">精彩视频</div>';
	echo '<div class="videolists">';
	$url = '';
	foreach($video_info as $v => $vv){
		echo '<div class="videoitem" onclick="opevides(\''. $vv['video'] .'\')">';
		echo '<img src="'.$vv['video'].'?x-oss-process=video/snapshot,t_10000,m_fast" />';
		echo '<text class="' . $css_class . '">' . t('exciting_video') . '</text>';
		echo '</div>';
		$url = $vv['video'] ;
	}
	
	echo '</div>';
	if($url){
	  echo '<div class="menu" style="width:100%;height:60px; margin-top:10px;margin-bottom:10px;">';
				echo '<div class="menubutton ' . $css_class . '" onclick="downloadVideo(\'' . $url . '\')">' . t('download_video') . '</div>';
        echo '</div>';
	}
}




$hio = $eagles =   $birdies = $parcounts = $boegeys = $dbbogeys =  $worst = 0;
$par3 = $par4 = $par5 = 0;
$outs = $ins =  0;
for ($r=$mt_round;$r>=1;$r--){
   // var_dump($roundgroups);
   $rdhio = $rdeagles =   $rdbirdies = $rdparcounts = $rdboegeys = $rddbbogeys =  $rdworst = 0;
	if ($roundgroups[$r]){
                            $sdata['scorecards'][($r-1)]['matchno'] = $roundgroups[$r]['match_no'];
                            $sdata['scorecards'][($r-1)]['matchtee'] = $roundgroups[$r]['tee'];
                          
                        } else {
                            $sdata['scorecards'][($r-1)]['matchno'] = '';
                            $sdata['scorecards'][($r-1)]['matchtee'] = '';
     }
    
	 $sdata['scorecards'][($r-1)]['roundtitle'] = $roundtext[$r];
	
    //if ($holeScore['score'][$r]){
	
	
	
        echo '<table class="altrowstable scoringtable poppin"><tbody>';
        echo '<tr>
                <th style="background-color:'.$color.';color:#fff;font-size:12px;" class="poppin">'. $roundtext[$r] .'</th>
                <th style="background-color:'.$color.';color:#fff;"  width="30" class="poppin">1</th>
                <th style="background-color:'.$color.';color:#fff;" width="30" class="poppin">2</th>
                <th style="background-color:'.$color.';color:#fff;" width="30" class="poppin" >3</th>
                <th style="background-color:'.$color.';color:#fff;" width="30" class="poppin">4</th>
                <th style="background-color:'.$color.';color:#fff;" width="30" class="poppin">5</th>
                <th style="background-color:'.$color.';color:#fff;" width="30" class="poppin">6</th>
                <th style="background-color:'.$color.';color:#fff;" width="30" class="poppin">7</th>
                <th style="background-color:'.$color.';color:#fff;" width="30" class="poppin">8</th>
                <th style="background-color:'.$color.';color:#fff;" width="30" class="poppin">9</th>                    
                <th style="background-color:'.$color.';color:#fff" class="poppin">OUT</th>
            </tr>';
        echo '<tr class="odd_player">
                <td style="font-size:12px;" class="' . $css_class . '">' . t('par') . '</td>';
        $out_total = $in_total = 0;
        for ($i=1;$i<10;$i++){
            echo '<td class="poppin">'.$pars["par"][$cl_id][($i-1)].'</td>';
            $out_total += $pars["par"][$cl_id][($i-1)];
        }
        echo '<td class="poppin">'.$out_total.'</td></tr>';
        //成绩
        echo '<tr class="even_player"><td style="font-size:12px;" class="' . $css_class . '">'.t('score').'</td>';
        $out_score = $in_score = 0;
        for ($h=1;$h<10;$h++){
            echo '<td  ><div class=" poppin '.toparcolor_detail($holeScore['topar'][$r][$pl_id][$h]).'">'.$holeScore['score'][$r][$pl_id][$h].'</div></td>';
            $out_score += $holeScore['score'][$r][$pl_id][$h];
			if($holeScore['score'][$r][$pl_id][$h]){
				if($pars["par"][$cl_id][($h-1)]==3){
					$par3 += $holeScore['topar'][$r][$pl_id][$h];
				}
				if($pars["par"][$cl_id][($h-1)]==4){
					$par4 += $holeScore['topar'][$r][$pl_id][$h];
				}
				if($pars["par"][$cl_id][($h-1)]==5){
					$par5 += $holeScore['topar'][$r][$pl_id][$h];
				}
				if($holeScore['topar'][$r][$pl_id][$h] <=-2){
					$eagles += 1;
					$rdeagles += 1;
				}
				if($holeScore['topar'][$r][$pl_id][$h] ==-1){
					$birdies += 1;
					$rdbirdies += 1;
				}
				if($holeScore['topar'][$r][$pl_id][$h] ==0){
					$parcounts += 1;
					$rdparcounts += 1;
				}
				if($holeScore['topar'][$r][$pl_id][$h] ==1){
					$boegeys += 1;
					$rdboegeys += 1;
				}
				if($holeScore['topar'][$r][$pl_id][$h] ==2){
					$dbbogeys += 1;
					$rddbbogeys += 1;
				}
				if($holeScore['topar'][$r][$pl_id][$h] >2){
					$worst += 1;
					$rdworst += 1;
				}
				if($holeScore['score'][$r][$pl_id][$h] == 1){
					$hio += 1;
					$rdhio += 1;
				}
				$outs+= $holeScore['topar'][$r][$pl_id][$h];
				
			}
			 $sdata['scorecards'][($r-1)]['outScore'][] = array(
                                    'holeNo'=>$h,
                                    'holeScore'=>($holeScore['score'][$r][$pl_id][$h]==null) ? '' : $holeScore['score'][$r][$pl_id][$h],
                                    'holepoint'=>0,
                                    'holetopar'=>($holeScore['topar'][$r][$pl_id][$h]==null) ? '' : $holeScore['topar'][$r][$pl_id][$h],
              );
			
        }
        echo '<td style="background:#fff;color:#000;">'.$out_score.'</td></tr>';

        echo '<tr>
             <th style="background-color:'.$color.';color:#fff;font-size:12px;">'.t('hole').'</th>
                <th style="background-color:'.$color.';color:#fff;" width="30" class="poppin" >10</th>
                <th style="background-color:'.$color.';color:#fff;" width="30" class="poppin" >11</th>
                <th style="background-color:'.$color.';color:#fff;" width="30" class="poppin" >12</th>
                <th style="background-color:'.$color.';color:#fff;" width="30" class="poppin" >13</th>
                <th style="background-color:'.$color.';color:#fff;" width="30" class="poppin">14</th>
                <th style="background-color:'.$color.';color:#fff;" width="30" class="poppin">15</th>
                <th style="background-color:'.$color.';color:#fff;" width="30" class="poppin">16</th>
                <th style="background-color:'.$color.';color:#fff;" width="30" class="poppin">17</th>
                <th style="background-color:'.$color.';color:#fff;" width="30" class="poppin">18</th>                    
                <th style="background-color:'.$color.';color:#fff" class="poppin">IN</th>
            </tr>';
        echo '<tr class="odd_player"><td class="' . $css_class . '" style="font-size:12px;">' . t('par') . '</td>';
        for ($i=10;$i<19;$i++){
            echo '<td class="poppin">'.$pars["par"][$cl_id][($i-1)].'</td>';
            $in_total += $pars["par"][$cl_id][($i-1)];
        }
        echo '<td class="poppin">'.$in_total.'</td></tr>';
        //成绩
        echo '<tr class="even_player"><td style="font-size:12px;" class="' . $css_class . '">'.t('score').'</td>';
        for ($h=10;$h<19;$h++){
            echo '<td ><div class="poppin  '.toparcolor_detail($holeScore['topar'][$r][$pl_id][$h]).'">'.$holeScore['score'][$r][$pl_id][$h].'</div></td>';
            $in_score += $holeScore['score'][$r][$pl_id][$h];
			
			if($holeScore['score'][$r][$pl_id][$h]){
				if($pars["par"][$cl_id][($h-1)]==3){
					$par3 += $holeScore['topar'][$r][$pl_id][$h];
				}
				if($pars["par"][$cl_id][($h-1)]==4){
					$par4 += $holeScore['topar'][$r][$pl_id][$h];
				}
				if($pars["par"][$cl_id][($h-1)]==5){
					$par5 += $holeScore['topar'][$r][$pl_id][$h];
				}
				if($holeScore['topar'][$r][$pl_id][$h] <=-2){
					$eagles += 1;
					$rdeagles += 1;
				}
				if($holeScore['topar'][$r][$pl_id][$h] ==-1){
					$birdies += 1;
					$rdbirdies += 1;
				}
				if($holeScore['topar'][$r][$pl_id][$h] ==0){
					$parcounts += 1;
					$rdparcounts += 1;
				}
				if($holeScore['topar'][$r][$pl_id][$h] ==1){
					$boegeys += 1;
					$rdboegeys += 1;
				}
				if($holeScore['topar'][$r][$pl_id][$h] ==2){
					$dbbogeys += 1;
					$rddbbogeys += 1;
				}
				if($holeScore['topar'][$r][$pl_id][$h] >2){
					$worst += 1;
					$rdworst += 1;
				}
				if($holeScore['score'][$r][$pl_id][$h] == 1){
					$hio += 1;
					$rdhio += 1;
				}
				$ins+= $holeScore['topar'][$r][$pl_id][$h];
			}
			 $sdata['scorecards'][($r-1)]['inScore'][] = array(
                                    'holeNo'=>$h,
                                    'holeScore'=>($holeScore['score'][$r][$pl_id][$h]==null) ? '' : $holeScore['score'][$r][$pl_id][$h],
                                    'holepoint'=>0,
                                    'holetopar'=>($holeScore['topar'][$r][$pl_id][$h]==null) ? '' : $holeScore['topar'][$r][$pl_id][$h],
              );
        }
		$rdtotalscores = $rdhio + $rdeagles + $rdbirdies + $rdparcounts + $rdboegeys + $rddbbogeys + $rdworst ;
		echo '<td style="background:#fff;color:#000;">' . $in_score . '</td></tr>';
		echo '</tbody></table>';
		echo '<div class="p_b poppin" style="height:40px; margin-top:1px;margin-bottom:10px; font-size:12px;display:flex;flex-direction:row;align-items:center;border-bottom:1px dotted #cfcfcf;position:relative;">'
				. t('roundR') . $r
				. (($rdhio) ? '<div style="margin-left:10px;width:10px;height:10px;border-radius:100%;background-color:#FFCC00"></div>'
						. '<div style="color:#FFCC00;width:auto;display:flex;flex-direction:row;" class="poppin">'
						. t('hole_in_one') . ':<text style="font-weight:900;">' . $rdhio . '</text>' . t('units') . '</div>' : '')
				. (($rdeagles) ? '<div style="margin-left:10px;width:10px;height:10px;border-radius:100%;background-color:#FFCC00"></div>'
						. '<div style="color:#FFCC00;width:auto;display:flex;flex-direction:row;" class="poppin">'
						. t('eagle') . ':<text style="font-weight:900;" class="poppin">' . $rdeagles . '</text>' . t('units') . '</div>' : '')
				. (($rdbirdies) ? '<div style="margin-left:10px;width:10px;height:10px;border-radius:100%;background-color:#DF212F"></div>'
						. '<div style="color:#DF212F;width:auto;display:flex;flex-direction:row;" class="poppin">'
						. t('birdie') . '<text style="font-weight:900;" class="poppin">' . $rdbirdies . '</text>' . t('units') . '</div>' : '')
				. (($rdparcounts) ? '<div style="margin-left:10px;width:10px;height:10px;border-radius:100%;background-color:#53565A"></div>'
						. '<div style="color:#53565A;width:auto;display:flex;flex-direction:row;" class="poppin">'
						. t('par_score') . '<text style="font-weight:900;" class="poppin">' . $rdparcounts . '</text>' . t('units') . '</div>' : '')
				. (($rdboegeys) ? '<div style="margin-left:10px;width:10px;height:10px;border-radius:100%;background-color:#1E90FF"></div>'
						. '<div style="color:#1E90FF;width:auto;display:flex;flex-direction:row;" class="poppin">'
						. t('bogey') . '<text style="font-weight:900;" class="poppin">' . $rdboegeys . '</text>' . t('units') . '</div>' : '')
				. (($rddbbogeys) ? '<div style="margin-left:10px;width:10px;height:10px;border-radius:100%;background-color:#473D98"></div>'
						. '<div style="color:#473D98;width:auto;display:flex;flex-direction:row;" class="poppin">'
						. t('double_bogey') . '<text style="font-weight:900;" class="poppin">' . $rddbbogeys . '</text>' . t('units') . '</div>' : '')
				. (($rdworst) ? '<div style="margin-left:10px;width:10px;height:10px;border-radius:100%;background-color:#000"></div>'
						. '<div style="color:#000;width:auto;display:flex;flex-direction:row;" class="poppin">'
						. t('over_three') . ' <text style="font-weight:900;" class="poppin">' . $rdworst . '</text>' . t('units') . '</div>' : '')
				. '<div style="position:absolute;width:100%;border-radius:2px;height:8px;bottom:1px;left:0px;display:flex;flex-direction:row;">'
				. (($rdhio) ? '<div style="width:' . ($rdhio / $rdtotalscores * 100) . '%;height:100%;background-color:#FFCC00"></div>' : '')
				. (($rdeagles) ? '<div style="width:' . ($rdeagles / $rdtotalscores * 100) . '%;height:100%;background-color:#FFCC00"></div>' : '')
				. (($rdbirdies) ? '<div style="width:' . ($rdbirdies / $rdtotalscores * 100) . '%;height:100%;background-color:#DF212F"></div>' : '')
				. (($rdparcounts) ? '<div style="width:' . ($rdparcounts / $rdtotalscores * 100) . '%;height:100%;background-color:#53565A"></div>' : '')
				. (($rdboegeys) ? '<div style="width:' . ($rdboegeys / $rdtotalscores * 100) . '%;height:100%;background-color:#1E90FF"></div>' : '')
				. (($rddbbogeys) ? '<div style="width:' . ($rddbbogeys / $rdtotalscores * 100) . '%;height:100%;background-color:#473D98"></div>' : '')
				. (($rdworst) ? '<div style="width:' . ($rdworst / $rdtotalscores * 100) . '%;height:100%;background-color:#000"></div>' : '')
				. '</div>'
				. '</div>';
		
		$sdata['scorecards'][($r-1)]['playerscore'] = ($holeScore['roundscore'][$r][$pl_id]) ? $holeScore['roundscore'][$r][$pl_id] : '';
		$sdata['scorecards'][($r-1)]['outScoretotal'] = ($out_score) ? $out_score : '';
		$sdata['scorecards'][($r-1)]['inScoretotal'] = ($in_total) ? $in_total : '';
    //}       
}

echo '<div id="mychart-pie" style="width:100%;height:200px;background-color:#fff; margin-top:50px;"></div>';

echo 

     '<table class="scoringtable topartable" border="0" cellpadding="0" cellspacing="0" width="100%">
				<tbody>
					<tr>
					   <td width="33%">
						   <div class="num poppin" style="color:#FFCC00;font-weight:bolder;">'.$eagles.'</div>
						  <div class="numdesc ' . $css_class . '">' . t('eagle') . '</div>
						</td>
						 <td width="33%">
							   <div class="num poppin" style="color:red;font-weight:bolder;">'.$birdies.'</div>
						 <div class="numdesc ' . $css_class . '">' . t('birdie') . '</div>
						</td>
						 <td width="33%">
						  <div class="num poppin" style="color:#53565A;font-weight:bolder;">'.$parcounts.'</div>
						 <div class="numdesc ' . $css_class . '">' . t('par_score') . '</div>
						</td>
					</tr>		
				</tbody>
	 </table>';

echo 

     '<table class="scoringtable topartable" border="0" cellpadding="0" cellspacing="0" width="100%">
				<tbody>
					<tr>
					   <td width="33%">
						  <div class="num poppin" style="color:#1E90FF;font-weight:bolder;">'.$boegeys.'</div>
						 <div class="numdesc ' . $css_class . '">' . t('bogey') . '</div>
						</td>
						 <td width="33%">
							   <div class="num poppin" style="color:#473D98;font-weight:bolder;">'.$dbbogeys.'</div>
						  <div class="numdesc ' . $css_class . '">' . t('double_bogey') . '</div>
						</td>
						 <td width="33%">
						  <div class="num poppin" style="color:#000;font-weight:bolder;">'.$worst.'</div>
						  <div class="numdesc">
							<font class="poppin">+2</font>
					      </div>
						</td>
					</tr>		
				</tbody>
	 </table>';

echo '<div id="mychart-radar" style="width:100%;height:200px;background-color:#fff;margin-top:10px;"></div>';        

echo 

     '<table class="scoringtable topartable" border="0" cellpadding="0" cellspacing="0" width="100%">
				<tbody>
				<tr>
    <!-- Par 3 Performance -->
    <td width="33%">
        <div class="num poppin"'. (($par3 < 0) ? ' style="color:#e50049;"' : '' ).'>'
            . ($par3 > 0 ? '+' . $par3 : ($par3 == 0 ? 'E' : $par3))
            . ($par3 > $avgscores['par3s'] ? '<text style="color:#1067ac">▲</text>' : ($par3 < $avgscores['par3s'] ? '<text style="color:#B7001F">▼</text>' : ''))
            . '</div>
        <div class="num agv poppin"'. (($avgscores['par3s'] < 0) ? ' style="color:#e50049;"' : '' ).'>'
            . '(' . ($avgscores['par3s'] > 0 ? '+' . $avgscores['par3s'] : ($avgscores['par3s'] == 0 ? 'E' : $avgscores['par3s'])) . ')'
            . '</div>
        <div class="numdesc ' . $css_class . '">'
            . t('par3_performance') .
            '</div>
    </td>

    <!-- Par 4 Performance -->
    <td width="33%">
        <div class="num poppin"'. (($par4 < 0) ? ' style="color:#e50049;"' : '' ).'>'
            . ($par4 > 0 ? '+' . $par4 : ($par4 == 0 ? 'E' : $par4))
            . ($par4 > $avgscores['par4s'] ? '<text style="color:#1067ac">▲</text>' : ($par4 < $avgscores['par4s'] ? '<text style="color:#B7001F">▼</text>' : ''))
            . '</div>
        <div class="num agv poppin"'. (($avgscores['par4s'] < 0) ? ' style="color:#e50049;"' : '' ).'>'
            . '(' . ($avgscores['par4s'] > 0 ? '+' . $avgscores['par4s'] : ($avgscores['par4s'] == 0 ? 'E' : $avgscores['par4s'])) . ')'
            . '</div>
        <div class="numdesc ' . $css_class . '">'
            . t('par4_performance') .
            '</div>
    </td>

    <!-- Par 5 Performance -->
    <td width="33%">
        <div class="num poppin"'. (($par5 < 0) ? ' style="color:#e50049;"' : '' ).'>'
            . ($par5 > 0 ? '+' . $par5 : ($par5 == 0 ? 'E' : $par5))
            . ($par5 > $avgscores['par5s'] ? '<text style="color:#1067ac">▲</text>' : ($par5 < $avgscores['par5s'] ? '<text style="color:#B7001F">▼</text>' : ''))
            . '</div>
        <div class="num agv poppin"'. (($avgscores['par5s'] < 0) ? ' style="color:#e50049;"' : '' ).'>'
            . '(' . ($avgscores['par5s'] > 0 ? '+' . $avgscores['par5s'] : ($avgscores['par5s'] == 0 ? 'E' : $avgscores['par5s'])) . ')'
            . '</div>
        <div class="numdesc ' . $css_class . '">'
            . t('par5_performance') .
            '</div>
    </td>
</tr>
				</tbody>
	 </table>';

echo 

     '<table class="scoringtable topartable" border="0" cellpadding="0" cellspacing="0" width="100%">
				<tbody>
					<tr>
					   <td width="33%">
						   <div class="num poppin"'. (($outs<0)?'style="color:#e50049;"':'' ).'>'.($outs>0?('+'.$outs):(($outs==0)?'E':$outs)).($outs >$avgscores['outs']? '<text style="color:#1067ac">▲</text>':($outs < $avgscores['outs']?'<text style="color:#B7001F">▼</text>':'')) . '</div>
						   <div class="num agv poppin"' . (($avgscores['outs']<0)?'style="color:#e50049;"':'' ).'>('.($avgscores['outs']>0?('+'.$avgscores['outs']):(($avgscores['outs']==0)?'E':$avgscores['outs'])).')</div>
						 
						  <div class="numdesc ' . $css_class . '">' . t('front_nine_performance') . '</div>
						</td>
						 <td width="33%">
						    <div class="num poppin"'. (($ins<0)?'style="color:#e50049;"':'' ).'>'.($ins>0?('+'.$ins):(($ins==0)?'E':$ins)).($ins >$avgscores['ins']? '<text style="color:#1067ac">▲</text>':($ins < $avgscores['ins']?'<text style="color:#B7001F">▼</text>':'')) . '</div>
						   <div class="num agv poppin"' . (($avgscores['ins']<0)?'style="color:#e50049;"':'' ).'>('.($avgscores['ins']>0?('+'.$avgscores['ins']):(($avgscores['ins']==0)?'E':$avgscores['ins'])).')</div>
						 
						  <div class="numdesc ' . $css_class . '">' . t('back_nine_performance') . '</div>
						</td>
						 <td width="33%">
					
						   <div class="num poppin"'. (($topar<0)?'style="color:#e50049;"':'' ).'>'.($topar>0?('+'.$topar):(($topar==0)?'E':$topar)).($topar >$avgscores['topar']? '<text style="color:#1067ac">▲</text>':($topar < $avgscores['topar']?'<text style="color:#B7001F">▼</text>':'')) . '</div>
						   <div class="num agv poppin"' . (($avgscores['topar']<0)?'style="color:#e50049;"':'' ).'>('.($avgscores['topar']>0?('+'.$avgscores['topar']):(($avgscores['topar']==0)?'E':$avgscores['topar'])).')</div>
						 
						 						  <div class="numdesc ' . $css_class . '">' . t('total_performance') . '</div>

						</td>
					</tr>		
				</tbody>
	 </table>'; 


echo '<div class="agv" style="height:30px;display:flex;flex-direction:row; align-items:center;width:100%;border-radius:10px; justify-content:center;font-size:10px;">
		<text style="margin-left:auto;color:#fff;margin-right:auto;" class="' . $css_class . '">' . t('average_scores') . '</text>
<text style="margin-left:auto;color:#fff;margin-right:auto;" class="' . $css_class . '">' . t('score_above_average') . '</text>
<text style="margin-left:auto;color:#fff;margin-right:auto;" class="' . $css_class . '">' . t('score_below_average') . '</text>
		</div>';      




function toparcolor_detail($score){
	if ($score==='0'){
		$color = 'par';
	}
    else  if (!empty($score)){
        if ($score<='-2'){
            $color = 'eagle';
        } else if ($score=='-1'){
            $color = 'birdie';
        } else if ($score===0){
            $color = 'par';
        } else if ($score=='1'){
            $color = 'bogey';
        } else if ($score=='2'){
            $color = 'dbbogey';
        } 
		else if ($score>='3'){
            $color = 'worse';
        } else {
            $color = '';
        }
    } else {
        $color = '';
    }
    return $color;
}
?>  


<--split-->


<?php
	
	  if ($pars){
              foreach ($pars['par'][$cl_id] as $i => $n){
						
                        $par[$i+1] = array('hole_id'=>$i+1, 'par'=>$pars["par"][$cl_id][($i)]);
                        if ($i <=9) $outin['out'] += $pars["par"][$cl_id][($i)];
                        if ($i >9) $outin['in'] += $pars["par"][$cl_id][($i)];
                        $outin['total'] += $pars["par"][$cl_id][($i)];
                    }
                    $sdata['holepars'] = array('hole'=>'hole', 'par'=>'par', 'outTotal'=>$outin['out'], 'inTotal'=>$outin['in'], 'Total'=>$outin['total']);
                     $sdata['pars'] = $pars;
                    //outInfo
                    for ($h=1; $h < 10; $h++){
                        $sdata['holepars']['outInfo'][] = array(
                            'holeNo'=>$h,
                            'holePar'=>$par[$h]['par'],
                        );
                    }
                    //inInfo
                    for ($h=10; $h < 19; $h++){
                        $sdata['holepars']['inInfo'][] = array(
                            'holeNo'=>$h,
                            'holePar'=>$par[$h]['par'],
                        );
                    }
                } else {
                    $sdata['holepars'] = array();
     }
	
	$sdata['parsperformans'] = array(
             'Par3s'=>($par3==0)?'E':$par3,
             'Par4s'=>($par4==0)?'E':$par4,
			 'Par5s'=>($par5==0)?'E':$par5,
    );
	
	$sdata['Inoutperformans'] = array(
             'outs'=>($outs==0)?'E':$outs,
             'ins'=>($ins==0)?'E':$ins,
         
    );
	
	$sdata['scoreperformans'] = array(
            'holeinone'=>($hio)?$hio:0,
			'eagle'=>($eagles)?$eagles:0,
			'birdie'=>($birdies)?$birdies:0,
			'par'=>($parcounts)?$parcounts:0,
			'boegey'=>($boegeys)?$boegeys:0,
			'dboegey'=>($dbbogeys)?$dbbogeys:0,
			'worse'=>($worst)?$worst:0,
           
    );
    $sdata['playername'] = ($lang=='CN'?$players['playerName'][$pl_id]:$players['playerEnName'][$pl_id]);
	
	$sdata['agvscoreperformans'] = array(
            'holeinone'=>($avgscores['avghios'])?$avgscores['avghios']:0,
			'eagle'=>($avgscores['avgeagles'])?$avgscores['avgeagles']:0,
			'birdie'=>($avgscores['avgbirdies'])?$avgscores['avgbirdies']:0,
			'par'=>($avgscores['avgpars'])?$avgscores['avgpars']:0,
			'boegey'=>($avgscores['avgboegeys'])?$avgscores['avgboegeys']:0,
			'dboegey'=>($avgscores['avgdboegeys'])?$avgscores['avgdboegeys']:0,
			'worse'=>($avgscores['avgworses'])?$avgscores['avgworses']:0,
			'Par3s'=>($avgscores['par3s'])?$avgscores['par3s']:0,
			'Par4s'=>($avgscores['par4s'])?$avgscores['par4s']:0,
			'Par5s'=>($avgscores['par5s'])?$avgscores['par5s']:0,
			'outs'=>($avgscores['outs'])?$avgscores['outs']:0,
			'ins'=>($avgscores['ins'])?$avgscores['ins']:0,
			'topar'=>($avgscores['topar'])?$avgscores['topar']:0,
			
           
    );
	
	
	echo json_encode($sdata);
?>

	
			
			


		



